import axiosInstance from "../../plugins/axios";
import { ElMessage } from "element-plus";



export const getPdrInfo = async (id: string) => {
  const res = await axiosInstance.post(
    `/pdr/get?id=${id}`
  );
  if (res.data.code == 1) {
    return res.data.data; // 返回数据
  } else {
    ElMessage.error(res.data.message || "PDR信息不存在");
    throw new Error(res.data.message || "PDR信息不存在");
  }
};

export const updatePdrInfo = async (formData: any) => {
  const res = await axiosInstance.post(
    `/pdr/update`,formData
  );
  if (res.data.code == 1) {
    return res.data.data; // 返回数据
  } else {
    ElMessage.error(res.data.message || "更新失败");
    throw new Error(res.data.message || "更新失败");
  }
};

export const uploadFile = async (file: any) => {
  const res = await axiosInstance.post(
    `/minio/upload`,file
  );
  if (res.data.code == 1) {
    return res.data.data; // 返回数据
  } else {
    ElMessage.error(res.data.message || "更新失败");
    throw new Error(res.data.message || "更新失败");
  }
};


